import axios from "axios";

const service = axios.create({
  baseURL: "http://192.168.10.182:3000", // api的base_url
  timeout: 20000, // request timeout
});

//请求拦截器
service.interceptors.request.use(
  (config) => {
    // if (store.getters.Token) {
    //   // 让每个请求携带token-- ['Token']为自定义key 请根据实际情况自行修改
    //   config.headers["与后端约定的token访问key"] = "拼接需要的访问key" + store.getters.Token;
    //   // config.headers["Authorization"] = "Bearer " + Token; //示例
    // }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

//响应拦截器
service.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default service;
